package com.syy.reducejoin;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class OrderJoinDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration configuration = new Configuration();
        Job job = Job.getInstance(configuration);

        job.setJarByClass(OrderJoinDriver.class);
        job.setMapperClass(OrderJoinMapper.class);
        job.setReducerClass(OrderJoinReducer.class);

        job.setMapOutputKeyClass(OrderJoin.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(OrderJoin.class);
        job.setOutputValueClass(NullWritable.class);

        job.setGroupingComparatorClass(OrderJoinGroup.class);

        FileInputFormat.setInputPaths(job, new Path("F:\\projects\\JavaProjects\\myproject\\JavaProjects\\MapReduceDemo\\src\\main\\resources\\input3\\*"));
        FileOutputFormat.setOutputPath(job, new Path("F:\\projects\\JavaProjects\\myproject\\JavaProjects\\MapReduceDemo\\src\\main\\resources\\output4"));

        boolean b = job.waitForCompletion(true);
        System.out.println(b?"成功":"失败");
    }
}
